package ui;

import java.io.IOException;
import java.util.List;
import java.util.NoSuchElementException;

import org.jsoup.nodes.Document;

import page.PageAnalyzer;
import page.PageParser;
import page.PageRetriever;

/**
 * Main class that runs the program.
 * 
 * @version February 6, 2012
 * @author Jay Fernandez
 */
public class Main {

	/**
	 * Main method.
	 * 
	 * @param args Command-line arguments.
	 */
	/*public static void main(String[] args) {
		String starting_address = "http://css.insttech.washington.edu/~mealden/";
		try {
			final PageRetriever retriever = new PageRetriever(starting_address);
			final PageAnalyzer analyzer = new PageAnalyzer();
			
			analyzer.addKeyword("the");
			analyzer.addKeyword("blah");
			analyzer.addKeyword("a");
			analyzer.addKeyword("link");
			analyzer.addKeyword("spot");
			
			Document currentDoc;
			while (true) {
				try {
					currentDoc = retriever.getNextPage();
					
					List<String> URLs = PageParser.parseURLs(currentDoc);
					retriever.addAllPages(URLs);
					analyzer.addURLs(URLs);
					
					analyzer.findKeywords(PageParser.parseWords(currentDoc));
					} catch (NoSuchElementException e) {
					break;
				}
			}
			
			System.out.println("Pages retrieved: " + analyzer.getPagesRetrieved());
			System.out.println("Average words per page: " + analyzer.getAvgWords());
			System.out.println("Average URLs per page: " + analyzer.getAvgURLs());
			String keyword;
			for (int i = 0; i < analyzer.getKeywords().size(); i++) {
				keyword = analyzer.getKeywords().get(i);
				System.out.print(keyword + ": ");
				System.out.print(analyzer.getTotalHits(keyword) + " | ");
				System.out.println(analyzer.getAvgHits(keyword));
			}
			
			
		} catch (IOException e) {
			System.out.println("Invalid URL");
		}
	}*/

}
